﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Text;
using System.Security.Cryptography;
using System.IO;

using CE.Global;

public partial class best_car_insurance_home : MyLanguageBasePage
{
    protected override void InitializeCulture()
    {
        String selectedCulture = CE.Global.General.SetCulture();
        base.InitializeCulture();
    }

    string selectedLanguage;
    protected void Page_Load(object sender, EventArgs e)
    {
        string _strCXLive = CE.Configuration.MyConfigurationManager.GetAppSettingValue("Mobile.IsCXLive");
        if (_strCXLive == "0")
        {
            if (Session[CE.Global.General.Guest] == null)
            {
                Response.Redirect("~/default.aspx");
            }
        }
        if (!IsPostBack)
        {
            ibtnLanguage.ImageUrl = Resources.BestCar.ButtonLanguageUrl;
        }
    }

    protected void ibtnLanguage_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        selectedLanguage = string.Empty;

        if (hdnLanguage.Value != string.Empty)
        {
            Session["Language"] = hdnLanguage.Value;
        }

        if (Session["Language"] != null)
        {
            selectedLanguage = Session["Language"].ToString();
        }
        else
        {
            selectedLanguage = "th-TH";
            Session["Language"] = selectedLanguage;
        }

        if (selectedLanguage == "th-TH")
        {
            Session["Language"] = "en-US";
            this.divLanguage.Attributes.Add("class", "flag-th");
            //ibtnLanguage.ImageUrl = "/mobile/best-car-insurance/images/icon/flag-th.png";
        }
        else
        {
            Session["Language"] = "th-TH";
            this.divLanguage.Attributes.Add("class", "flag-en");
            //ibtnLanguage.ImageUrl = "/mobile/best-car-insurance/images/icon/flag-en.png";
        }

        hdnLanguage.Value = selectedLanguage;

        Response.Redirect(Request.UrlReferrer.AbsoluteUri);
    }

}
